#include <bits/stdc++.h>
#define pb push_back

using namespace std;

typedef double db;
typedef struct {int v,w;} edge;
const int MAXN = 1e5+10;

int n,m,to[MAXN];
vector<edge> G[MAXN];
db f[MAXN],g[MAXN];

int main(){
	scanf("%d %d",&n,&m); for(int i = 1;i <= m;i++){int x,y,w;scanf("%d %d %d",&x,&y,&w);G[x].pb(edge{y,w});to[y]++;}
	queue<int>q;f[1] = 1.0,g[1] = 0;q.push(1);
	while(q.size()){
		int x = q.front();q.pop();db per = f[x] / G[x].size();
		for(int i = 0;i < G[x].size();i++){
			int y = G[x][i].v,w = G[x][i].w;
			f[y] += per;g[y] += g[x] / G[x].size()+ w * per;
			to[y]--;if(!to[y]) q.push(y);
		}
	}
	printf("%.2lf",g[n]);return 0;
}
